package com.zy.cat.entity.dev.repository;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.zy.cat.entity.dev.CatDevHCInviteIncomeHistory;
 
public interface CatDevHCInviteIncomeHistoryRepository extends JpaSpecificationExecutor<CatDevHCInviteIncomeHistory>,  JpaRepository<CatDevHCInviteIncomeHistory, String>{
	/**
	 * 
	 * @info 查询当前24小时内的邀请进度信息
	 * @author Link
	 * @date 2019-11-28 16:55
	 * @param pid
	 * @return
	 */
	@Query("from CatDevHCInviteIncomeHistory where pid=:pid and NOW()>=stime and etime>=NOW() and hstatus=0")
	List<CatDevHCInviteIncomeHistory> getInviteInfos(@Param("pid")String pid);
 
	/**
	 * getInviteInfos
	 * @info 修改本轮邀请奖励为成功
	 * @author Link
	 * @date 2019-11-28 16:54
	 * @param pid
	 * @return
	 */
	@Transactional
	@Modifying
	@Query("update CatDevHCInviteIncomeHistory set hstatus=1 where pid=:pid and NOW()>=stime and etime>=NOW() and hstatus=0")
	int updInviteInfos(@Param("pid")String pid);
}
